<?php

/*
 * Pagina de idiomas
 * 
 */

class Idiomas extends Controller {

    function Idiomas() {
        parent::Controller();

        $this->load->library('session');
        $this->load->language('general',$this->session->userdata('lenguaje'));

    }

    function index() {

    }
    
    function idioma() {
        $leng = $this->uri->segment(3);
        $this->load->library('session');
        $this->session->set_userdata(array('lenguaje' => $leng));

        $sql = "SELECT * FROM general";
        $query = $this->db->query($sql);
        $res=$query->result();//para calcular la cantidad de registros


        if(count($res)!=0) {
            $query = $this->db->query("UPDATE general set idioma='".$leng."'");
        }else {
            $query = $this->db->query("INSERT INTO general set idioma='".$leng."'");
        }

        redirect('/home/');
    }

    /**
     * Actualmente no implementado
     */
    function idioma2() {
        $leng = $this->uri->segment(3);
        //$leng = $this->input->post('len');

        $this->load->library('session');
        $this->session->set_userdata(array('lenguaje' => $leng));
        redirect('/home/');
    }

}

?>
